home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1998 #4
/
Amiga Plus CD - 1998 - No. 4.iso
/
pd
/
grafik
/
metaview
/
slideshowmv
< prev
next >
Wrap
Text File
|
1997-11-26
|
9KB
|
328 lines
/* Program to use Metaview to display a whole directory of files, including subdirectories. An assign to Metaview: is needed. */
/* Written by Don Cox, Nov 97. Copyright, not Public Domain. */
/* $VER:SlideShowMV Nov19 97 */
call open("STDERR","ram:traceSS","W")
trace r
options results
numeric digits 14
/* +++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ */
address command
dir1 = getclip('FileSortIn')
if dir1 ~= "" then 'requestfile >ram:answer DRAWER "'dir1'" TITLE "Source Directory" DRAWERSONLY'
else 'requestfile >ram:answer TITLE "Source Directory" DRAWERSONLY'
call open("answer","ram:answer",'R')
directory = strip(readln("answer"),'B','"')
call setclip('FileSortIn',directory)
'REQUESTCHOICE >ram:rcnum1 "Display Time" "Seconds per image" "1|3|5|7|Abort"'
call open("answer3","ram:rcnum1")
rcn = readln("answer3")
SecsPerImage = rcn
if rcn = 0 then exit
/* Looking for our start process */
/*
** Create a new Metaview process:
** first look for the allready running processes
** then the new Port will be the next one
*/
do NUMBER = 0 to 20
if (SHOW(PORTS,"METAVIEW." || NUMBER) = 0) then
leave
end
/*
** Searching for MetaView: 1. our path above,
** 2. path in env:MetaView.path
** or 3. you must have a assign "MetaView:"
*/
if (EXISTS(METAVIEW)=0) then do
if OPEN("MVVAR","env:MetaView.path","Read") then do
METAVIEW = READLN("MVVAR")
METAVIEWpath= getpath(METAVIEW)
address command
'assign METAVIEW: 'METAVIEWpath
end
if (EXISTS(METAVIEW)=0) then do
METAVIEW = "MetaView:MetaView"
end
end
/*
** Enable warnings for WaitForPort
*/
OPTIONS FAILAT 5
ADDRESS COMMAND
"run " || METAVIEW
MVPORT = "METAVIEW." || NUMBER
"WaitForPort " || MVPORT
address value MVPORT
/* Display files in one directory and its descendents */
imagecount = 1
newfile = ""
oldfile = ""
address command
'delete Metaview:dirlist1'
'delete Metaview:dirlist'
'list >Metaview:dirlist1 "'directory'" dirs all LFORMAT="%P%S"'
'sort from Metaview:dirlist1 to Metaview:dirlist'
call open("dirinput","Metaview:dirlist","r")
/* First display pics in root directory */
'delete Metaview:filelist1'
'delete Metaview:filelist'
'list >Metaview:filelist1 "'directory'" files LFORMAT="%P%S"'
call open('input',"Metaview:filelist1","r") /* test in case it's empty */
listtest = readln('input')
call close('input')
if listtest~="" then do
'sort from Metaview:filelist1 to Metaview:filelist'
call dirdisplay
end
/* Now do all the subdirectories */
if~exists("Metaview:dirlist") then wayout()
listtest = readln("dirinput")
call seek("dirinput",0,'B')
dirtrees = 0
if listtest~="" then do
'REQUEST "Show images in Subdirectories?" "Yes|No"'
dirtrees = rc
end
do d = 1 to 700
dirname = readln("dirinput")
if dirname = "" then break
address command
'delete Metaview:filelist1'
'delete Metaview:filelist'
'list >Metaview:filelist1 "'dirname'" files LFORMAT="%P%S"'
call open('input2',"Metaview:filelist1","r") /* test in case it's empty */
listtest = readln('input2')
call close('input2')
if listtest~="" then do
'sort from Metaview:filelist1 to Metaview:filelist'
call dirdisplay
end
end
wayout:
address value MVPORT
'REQUEST " Finished "'
exit
end
/* ++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ */
getpath:
parse arg allname
pos1 = lastpos("/",allname)
if pos1 = 0 then pos1 = lastpos(":",allname)
filepath = left(allname,pos1)
return filepath
getname:
parse arg allname
pos1 = lastpos("/",allname)
if pos1 = 0 then pos1 = lastpos(":",allname)
justname = substr(allname,pos1+1)
return justname
expandfilename: procedure
parse arg jfile;
if index(jfile,':') = 0 then do
curdir = pragma(D);
if right(curdir,1) ~= ':' then do
if right(curdir,1) ~= '/' then do
if curdir ~= '' then do
curdir = curdir || '/';
end;
end;
end;
jfile = curdir||jfile;
end;
return jfile
rounded: procedure
parse arg number
originalNumber = number
number = trunc(number)
if (originalNumber-number)>0.5 then number=number+1
return number
/* ++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++*/
/* Display all the pics in one directory */
dirdisplay:
address value MVPORT
call open('input3',"Metaview:filelist","r")
do i = 1 to 7000 /* safety limit of 7000 files */
filename = readln('input3')
if filename = "" then break
slashpos = lastpos("/",filename)
dotpos = lastpos(".",filename)
if dotpos<slashpos then dotpos = 0 /* not dots in directory names */
if dotpos~=0 then extension = upper(substr(filename,dotpos))
else extension = ""
extensionlist = ".INFO .ILBM .GIF .PSFONT .FONT .PDFONT .PFB .AFM .METRIC .LIB .DEM .DOC .TXT .WP .README .ME .ZIP .ARC .ME .DAT .EXE .PIF .INI .TF .DB .C .H .GF .PPRX .PDRX .REXX .ADPRO .CFG .PREFS .HTM .HTML"
if pos(upper(extension),extensionlist)~=0 then iterate i
if word(filename,2) = "files" then iterate i /* This line not a file name */
if filename="Ram:traceSS" then iterate i
if word(filename,1) = "TOTAL:" then break /* or this one */
if upper(extension) = ".LHA" then call UnArc()
else success = showpic()
end /* end of directory */
call close('input3')
return
/* +++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */
showpic:
if ~open("picinput",filename,"R") then return 1
chunks = readch("picinput",1000)
call close("picinput")
address value MVPORT
'LOAD "'filename'"' /* Quotes allow file names with spaces */
if rc ~=0 then return 1 /* if load fails, try the next one */
newfile = result
address command
"wait "SecsPerImage
address value MVPORT
return 0
/* ++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */
/* Unarchive LHA files to HD and display temporary dir */
UnArc:
if ~exists("c:lha") then return 1
address command
if exists("Metaview:ssarc") then 'delete Metaview:ssarc all' /* gets rid of any crash-producing files left from previous run */
'makedir Metaview:ssarc'
'lha e -f "'filename'" Metaview:ssarc/'
/* Display files in archive directory and its descendents. LHA files within LHA files are NOT expanded. */
arcimagecount = 1
address command
'delete Metaview:arcdirlist1'
'delete Metaview:arcdirlist'
'list >Metaview:arcdirlist1 Metaview:ssarc dirs all LFORMAT="%P%S"'
'sort from Metaview:arcdirlist1 to Metaview:arcdirlist'
call open("arcdirinput","Metaview:arcdirlist","r")
/* First display pics in root directory */
'delete Metaview:arcfilelist1'
'delete Metaview:arcfilelist'
'list >Metaview:arcfilelist1 Metaview:ssarc files LFORMAT="%P%S"'
call open('arcinput',"Metaview:arcfilelist1","r") /* test in case it's empty */
listtest = readln('arcinput')
call close('arcinput')
if listtest~="" then do
'sort from Metaview:arcfilelist1 to Metaview:arcfilelist'
call arcdirdisplay
end
/* Now do all the archive subdirectories */
if~exists("Metaview:arcdirlist") then return
listtest = readln("arcdirinput")
call seek("arcdirinput",0,'B')
do d = 1 to 700
arcdirname = readln("arcdirinput")
if arcdirname = "" then break
address command
'delete Metaview:arcfilelist1'
'delete Metaview:arcfilelist'
'list >Metaview:arcfilelist1 "'arcdirname'" files LFORMAT="%P%S"'
call open('arcinput2',"Metaview:arcfilelist1","r") /* test in case it's empty */
listtest = readln('arcinput2')
call close('arcinput2')
if listtest~="" then do
'sort from Metaview:arcfilelist1 to Metaview:arcfilelist'
address "IMAGEENGINEER"
call arcdirdisplay
end
end
call close("arcdirinput")
'delete Metaview:ssarc all'
return
/* +++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++ */
arcdirdisplay:
call open('inputarc',"Metaview:arcfilelist","r")
do a = 1 to 7000 /* safety limit of 7000 files */
address command
filename = readln('inputarc')
if filename = "" then break
slashpos = lastpos("/",filename)
dotpos = lastpos(".",filename)
if dotpos<slashpos then dotpos = 0 /* not dots in directory names */
if dotpos~=0 then extension = upper(substr(filename,dotpos))
else extension = ""
/* Note: this time filter out LHA files */
extensionlist = extensionlist||" .LHA"
if pos(upper(extension),extensionlist)~=0 then iterate a
if word(filename,2) = "files" then iterate /* This line not a file name */
if left(filename,9)="Ram:trace" then iterate
if word(filename,1) = "TOTAL:" then break /* or this one */
success = showpic()
end /* end of directory */
call close('inputarc')
return 0